require(['./config'], () => {
	require(['swiperm','template','urlSet','swiper','header','footer'],(Swiperm,template,urlSet) => {
		class Index{
			constructor() {
			    this.render().then(() => {
					this.goTo()
					
				})
			}
			
			render () {
				return new Promise (resolve => {
					$.get(urlSet.indexUrl,resp => {
						let typeList = resp.data.topList.slice(0,4)
						typeList = typeList.filter(typeList => typeList.expireDate)
						$('.carType').html(template('carTypeTemplate',{typeList}))
					resolve()
					})
				})
			}
			
			goTo() {
				$('.carType').on('click','.img img',function () {
					const id = $(this).parents('ul').attr('data-id')
					window.open(`/html/detail.html?id=${id}`,'_self')
				})
				$('.carType').on('click','dt',function () {
					const id = $(this).parents('ul').attr('data-id')
					window.open(`/html/detail.html?id=${id}`,'_self')
				})
			}
		}
		new Index()
	})
})